package com.amado.easyui2.service.impl;

import java.util.List;

import com.amado.easyui2.dao.DepartmentDao;
import com.amado.easyui2.dao.impl.DepartmetDaoMysqlImpl;
import com.amado.easyui2.domain.Department;
import com.amado.easyui2.service.DepartmentService;
import com.amado.easyui2.vo.Page;
public class DepartmentServiceImpl implements DepartmentService {
	private DepartmentDao departmentDao = new DepartmetDaoMysqlImpl();

	@Override
	public boolean add(Department department) {
		if (department != null) {
			departmentDao.add(department);
			return true;
		}
		return false;
	}

	@Override
	public  List<Department> list() {
		return departmentDao.listAll();
	}

	@Override
	public boolean delete(Long id) {
		if (id != null) {
			departmentDao.delete(id);
			return true;
		}
		return false;
	}

	@Override
	public boolean update(Department department) {
		if(department!=null) {
			departmentDao.update(department);
			return true;
		}
		return false;
	}

	@Override
	public Page<Department> listAll(Page page) {
		int total = departmentDao.listAllCount();
		Page<Department> newPage  = new Page<>();
		newPage.setTotal(total);
		newPage.setRows(departmentDao.listAll(page));
		return newPage;
	}

	@Override
	public List<Department> listAll() {
		return departmentDao.listAll();
	}

}
